Exporting plots

You can save the current view of a plot using the interactive save tool from Bokeh. Depending on the size of your plot you might need to click on the three little dots to see the tool in the menu.

You can also save plots programmatically using the GenomeBrowser.save function. Note that this function will only save the initial version of the plot and not the current view.

Saving plots requires selenium and geckodriver. Please refer to the Bokeh documentation in case of problem.

Saving to svg

Plots can only be saved to svg if you initialise your GenomeBrowser using output_backend="svg". When mutliple tracks are displayed, an individual svg file will be saved for each track, as well as a combined svg file.

import genomenotebook as gn
import os
import pandas as pd
data_path = gn.get_example_data_dir()
gff_path = os.path.join(data_path, "MG1655_U00096.gff3")

data=pd.DataFrame(dict(x=np.arange(0,5000,100),
                       y=np.sin(np.arange(0,5000,100))))

g=gn.GenomeBrowser(gff_path=gff_path, 
                bounds=(0,5000),
                output_backend="svg",
                search=False)

track = g.add_track(height=100)
track.scatter(data=data, pos="x", y="y")
g.show()
g.save("test.svg")

Saving to png

You can increase the height and width to obtain a better resolution.

g=gn.GenomeBrowser(gff_path=gff_path,
                   bounds=(0,5000),
                   search=False,
                   height=200,
                   width=2000,
                   label_font_size="20pt")
g.save("test.png")